package cn.itcast.dubbo.service.impl;

import cn.itcast.dubbo.common.ReadOnly;
import cn.itcast.dubbo.pojo.User;
import cn.itcast.dubbo.service.ApiUserService;
import com.alibaba.dubbo.config.annotation.Service;

import java.util.ArrayList;
import java.util.List;
//不同版本

@Service(version = "${dubbo.service.version}")
public class ApiUserServiceImpl implements ApiUserService {
    @Override
    public List<User> QueryAll() {
        List<User> list = new ArrayList<>();
        for(int i=0;i<10;i++){
            User u = new User();
            u.setAge(10+i);
            list.add(u);
        }
        System.out.println("------------service 1");
        return list;
    }

    @Override
    @ReadOnly
    public User getUser() {
        User u = new User();
        u.setAge(10);
        u.setUsername("胡剑峰");
        System.out.println("----------service 3");
        return u;
    }
}
